package com.xkdx.guangguang.fragment.shopinfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.R.integer;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.xkdx.caipiao.R;
import com.xkdx.guangguang.ManagerActivity;
import com.xkdx.guangguang.adapter.NewsInfoAdapter;
import com.xkdx.guangguang.adapter.ShopCommentAdapter;
import com.xkdx.guangguang.card.CardInfoFragment;
import com.xkdx.guangguang.fragment.BaseFragment;
import com.xkdx.guangguang.fragment.map.SingleShopMapFragment;
import com.xkdx.guangguang.fragment.newsinfo.DiscountFragment;
import com.xkdx.guangguang.fragment.newsinfo.NewsFragment;
import com.xkdx.guangguang.fragment.shop.brandofshop.BrandsOfShopFragment;
import com.xkdx.guangguang.fragment.shop.photo.PhotoAlbumFragment;
import com.xkdx.guangguang.fragment.user.UserSharePrefence1;
import com.xkdx.guangguang.fragment.web.WebFragment;
import com.xkdx.guangguang.module.network.AbsModule;
import com.xkdx.guangguang.module.statics.IConstants;
import com.xkdx.guangguang.module.util.ShopCommentUtil;
import com.xkdx.guangguang.presistence.attention.AttentionShopAction;
import com.xkdx.guangguang.presistence.attention.AttentionShopModule;
import com.xkdx.guangguang.presistence.attention.AttentionShopPresistence;
import com.xkdx.guangguang.shareclass.DaZhongBean;
import com.xkdx.guangguang.shareclass.DaZhongDetailBean;
import com.xkdx.guangguang.shareclass.DiscountInfo;
import com.xkdx.guangguang.shareclass.Shop;
import com.xkdx.guangguang.shareclass.ShopCommentary;
import com.xkdx.guangguang.shareclass.ShopDetail;
import com.xkdx.guangguang.sql.AttentionDataHelper;
import com.xkdx.guangguang.util.DaZhongApiTool;
import com.xkdx.guangguang.util.SharePrefenceUtil;
import com.xkdx.guangguang.wiget.XListView;
import com.xkdx.guangguang.wiget.XListView.IXListViewListener;

public class ShopInfoFragment extends BaseFragment implements OnClickListener,
		IXListViewListener {
	View view;
	public static Map<String, Integer> attentionShop = new HashMap<String, Integer>();
	View subview_shopdetail, subview_comment, subview_newsinfo;
	TextView title_news, title_comment, title_shopdetail, title_brandofshop;
	Button edit;
	ImageView back;
	LinearLayout container, attention;
	LayoutInflater inflater;
	TextView attentionCount, shop_title;
	ImageLoader imageLoader = ImageLoader.getInstance();
	String shopID;
	Shop shop;
	int PageIndex = 1;
	View card_link_view;
	ImageView card_link;
	ImageView focuse_im;
	DisplayImageOptions focuse_options;
	NewsInfoAdapter newsAdapter;
	boolean isLoadMore = false;
	// subview_shopdetail控件
	TextView shop_detail_blog, shop_detail_net, shop_detail_map,
			shop_detail_tel, shop_detail_shopintrol;
	ImageView shop_detail_blog_icon, shop_detail_net_icon,
			shop_detail_map_icon, shop_detail_tel_icon;
	ImageView newsTipImage;
	ShopDetail shopDetail;
	ImageView iv_addvfirst, iv_addvsecond, iv_addvthird;
	// subview_comment控件
	ListView commentListView;
	List<ShopCommentary> shopCommentList;
	List<DaZhongDetailBean> daZhongList;

	// subview_newsinfo控件
	XListView newsListView;
	List<DiscountInfo> newInfoList;

	// Task
	ShopInfoAction shopInfoAction;
	ShopInfoModule shopInfoModule;
	ShopInfoPersister shopInfoPersister;

	// 关注Task
	AttentionShopAction attentionShopAction;
	AttentionShopModule attentionShopModule;
	AttentionShopPresistence attentionShopPresistence;
	// 查看更多优惠信息
	ShopInfoNewsAction shopInfoNewsAction;
	ShopInfoNewsModule shopInfoNewsModule;
	ShopInfoNewsPresistence shopInfoNewsPresistence;

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		inflater = LayoutInflater.from(getActivity());
		shopID = getArguments().getString("shopID");
		focuse_options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.focus_image)
				.showImageForEmptyUri(R.drawable.focus_image)
				.showImageOnFail(R.drawable.focus_image)
				.resetViewBeforeLoading().cacheOnDisc()
				.imageScaleType(ImageScaleType.EXACTLY)
				.bitmapConfig(Bitmap.Config.RGB_565).build();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.shop_home, container, false);
		findView();
		setOnClick();
		showLoading();
		return view;
	}

	@Override
	public void findView() {
		IConstants.hideInputMethodAways(getActivity(), view);
		shopInfoAction = new ShopInfoAction(shopID, "1900-1-1", "1900-1-1");
		shopInfoModule = new ShopInfoModule();

		container = (LinearLayout) view.findViewById(R.id.container);
		attention = (LinearLayout) view.findViewById(R.id.attention);
		title_news = (TextView) view.findViewById(R.id.title_newsinfo);
		title_comment = (TextView) view.findViewById(R.id.title_comment);
		title_shopdetail = (TextView) view.findViewById(R.id.title_shopdetail);
		title_brandofshop = (TextView) view
				.findViewById(R.id.title_brandofshop);
		shop_title = (TextView) view.findViewById(R.id.shop_title);
		attentionCount = (TextView) view.findViewById(R.id.number);
		focuse_im = (ImageView) view.findViewById(R.id.adverse);

		back = (ImageView) view.findViewById(R.id.title_shop_info_back_btn);
		edit = (Button) view.findViewById(R.id.shop_info_edit_upload_btn);
		UserSharePrefence1 su = new UserSharePrefence1(getActivity(),
				IConstants.SP_USER_NEW);
		String type = su.getUsertype();
		String shopIds = su.getShopids();
		String[] shopids = shopIds.split(",");
		if ((type.equals("2") || type.equals("3"))) {
			if(shopids.length > 0) {
				for(int i = 0; i< shopids.length;i++) {
					if(shopids[i].equals(shopID)) {
						edit.setVisibility(View.VISIBLE);
						edit.setClickable(true);
					}
				}
			}

		}
		subview_shopdetail = inflater.inflate(R.layout.shop_info_detail, null);
		subview_newsinfo = inflater
				.inflate(R.layout.shop_detail_newsinfo, null);
		subview_comment = inflater.inflate(R.layout.shop_detail_comment, null);
		initSubView();

	}

	@Override
	public void setOnClick() {

		title_news.setOnClickListener(this);
		title_comment.setOnClickListener(this);
		title_shopdetail.setOnClickListener(this);
		title_brandofshop.setOnClickListener(this);

		shop_detail_blog_icon.setOnClickListener(this);
		shop_detail_net_icon.setOnClickListener(this);
		shop_detail_map_icon.setOnClickListener(this);
		shop_detail_tel_icon.setOnClickListener(this);

		back.setOnClickListener(this);
		attention.setOnClickListener(this);
		focuse_im.setOnClickListener(this);
		edit.setOnClickListener(this);
		card_link.setOnClickListener(this);

	}

	private void initSubView() {
		shop_detail_shopintrol = (TextView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_shopintro_tv);
		shop_detail_blog = (TextView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_blog_tv);
		shop_detail_map = (TextView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_map_tv);
		shop_detail_net = (TextView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_net_tv);
		shop_detail_tel = (TextView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_tel_tv);
		iv_addvfirst = (ImageView) subview_shopdetail
				.findViewById(R.id.iv_addvfirst);
		iv_addvsecond = (ImageView) subview_shopdetail
				.findViewById(R.id.iv_addvsecond);
		iv_addvthird = (ImageView) subview_shopdetail
				.findViewById(R.id.iv_addvthird);

		shop_detail_blog_icon = (ImageView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_blog_icon);
		shop_detail_net_icon = (ImageView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_net_icon);
		shop_detail_map_icon = (ImageView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_map_icon);
		shop_detail_tel_icon = (ImageView) subview_shopdetail
				.findViewById(R.id.shop_info_detail_tel_icon);

		commentListView = (ListView) subview_comment
				.findViewById(R.id.shop_detail_shopcomment_listview);
		newsListView = (XListView) subview_newsinfo
				.findViewById(R.id.shop_detail_newslistview);
		newsListView.setPullRefreshEnable(false);
		newsListView.setPullLoadEnable(true);
		
		card_link_view = (View) subview_newsinfo.findViewById(R.id.ic_card_link);
		card_link = (ImageView) card_link_view.findViewById(R.id.card_link_im);
		newsTipImage = (ImageView) subview_newsinfo
				.findViewById(R.id.default_image);

	}

	@Override
	public void showLoading() {
		dataLoadDialog.show();
		shopInfoPersister = new ShopInfoPersister(this);
		if (IConstants.isCommitSuccess) {
			shopInfoPersister.mUseCache = false;
		} else {
			shopInfoPersister.mUseCache = true;
		}
		shopInfoPersister.setActitons(shopInfoAction);
		shopInfoPersister.setModule(shopInfoModule);
		shopInfoPersister.execute();
		dataLoadDialog.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				if (shopInfoPersister != null) {
					shopInfoPersister.cancel(true);
				}
				getFragmentManager().popBackStack();

			}
		});
		dataLoadDialog.show();

	}

	@Override
	public void showLoaded(HashMap<String, AbsModule> map) {
		if (dataLoadDialog != null && dataLoadDialog.isShowing()) {
			dataLoadDialog.dismiss();
		}
		if (map.containsKey("0")) {
			shopInfoModule = (ShopInfoModule) map.get("0");
			newInfoList = shopInfoModule.newInfoList;
			shopCommentList = shopInfoModule.shopCommentList;
			IConstants.Shop_CommentNum = shopInfoModule.shopCommentNum;
			shopDetail = shopInfoModule.shopDetail;
			setView();
			setDetailValuse();
			setNewsInfo();
			container.removeAllViews();
			container.addView(subview_newsinfo);
			DaZhongTask daZhongTask = new DaZhongTask(
					shopDetail.getDianpingShopID());
			daZhongTask.execute();
		} else {
			refresh(map);
		}
	}

	private void setView() {
		shop_title.setText(shopDetail.getShopName());
		if (attentionShop.containsKey(shopID)) {
			attentionCount.setText(attentionShop.get(shopID) + "");
		} else {
			attentionCount.setText(shopDetail.getAttentionCount());
		}
		if (shopDetail.getPictureList() != null
				&& shopDetail.getPictureList().size() != 0)
			imageLoader.displayImage(shopDetail.getPictureList().get(0),
					focuse_im, focuse_options);

	}

	private void setComment() {
		ShopCommentAdapter commentAdapter = new ShopCommentAdapter(this,
				shopCommentList, daZhongList, imageLoader, shopID,
				shop.getShopName(), false);
		commentListView.setAdapter(commentAdapter);

	}

	private void setNewsInfo() {
		if (newInfoList.size() != 0) {
			newsAdapter = new NewsInfoAdapter(getActivity(), newInfoList,
					imageLoader);
			card_link_view.setVisibility(View.GONE);
			View view=LayoutInflater.from(getActivity()).inflate(R.layout.card_info_link_im, null);
			ImageView im=(ImageView)view.findViewById(R.id.card_link_im);
			im.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					CardInfoFragment cardInfoFragment = new CardInfoFragment();
					Bundle b = new Bundle();
					b.putString(CardInfoFragment.CON1, "shop");
					b.putString(CardInfoFragment.CON1VALUE, shopID);
					cardInfoFragment.setArguments(b);
					getFragmentManager().beginTransaction()
							.replace(R.id.fragment, cardInfoFragment)
							.addToBackStack(null).commit();

				}
			});
			newsListView.addHeaderView(view);
			newsListView.setAdapter(newsAdapter);

			// newsListView.setXListViewListener(null);
			newsListView.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id) {
					String infoType = newInfoList.get(position-2)
							.getInfoType();
					FragmentTransaction ft = getFragmentManager()
							.beginTransaction();
					if (infoType.equals("1")) {
						DiscountFragment discountFragment = new DiscountFragment();
						ft.replace(R.id.fragment, discountFragment);
						Bundle b = new Bundle();
						b.putString("infoID", newInfoList.get(position-2)
								.getInfoID());
						discountFragment.setArguments(b);
						ft.addToBackStack(null);
						ft.commit();
					} else {
						NewsFragment newsFragment = new NewsFragment();
						ft.replace(R.id.fragment, newsFragment);
						Bundle b = new Bundle();
						b.putString("infoID", newInfoList.get(position-2)
								.getInfoID());
						newsFragment.setArguments(b);
						ft.addToBackStack(null);
						ft.commit();
					}

				}
			});

			newsListView.setXListViewListener(this);
		} else {
			card_link_view.setVisibility(View.VISIBLE);
			newsTipImage.setVisibility(View.VISIBLE);
		}

	}

	private void setShop() {
		if (shop == null) {
			shop = new Shop();
		}
		shop.setShopID(shopDetail.getShopID());
		shop.setShopName(shopDetail.getShopName());
		shop.setShopType(shopDetail.getShopType());
		shop.setLogo(shopDetail.getLogo());
		shop.setLatitude(shopDetail.getLatitude());
		shop.setLongitude(shopDetail.getLongitude());
	}

	private void setDetailValuse() {
		setShop();
		String net = shopDetail.getWebSiteUrl();
		if (net.equals("")) {
			shop_detail_net.setText("暂时没有官网地址");
		} else {
			shop_detail_net.setText("官网：" + shopDetail.getWebSiteUrl());
		}
		String weibo = shopDetail.getWeibo();
		if (weibo.equals("")) {
			shop_detail_blog.setText("暂时没有微博");
		} else {
			shop_detail_blog.setText("微博：" + shopDetail.getWeibo());
		}

		shop_detail_map.setText(shopDetail.getAddress());
		shop_detail_tel.setText("电话：" + shopDetail.getPhone());
		shop_detail_shopintrol.setText(shopDetail.getIntro());

		if (!"False".equals(shopDetail.getIcon1())) {
			iv_addvfirst.setVisibility(View.VISIBLE);
			iv_addvfirst.setImageResource(R.drawable.shop_guan_v);
		} else {
			iv_addvfirst.setVisibility(View.GONE);
		}
		if (!"False".equals(shopDetail.getIcon2())) {
			iv_addvsecond.setVisibility(View.VISIBLE);
			iv_addvsecond.setImageResource(R.drawable.shop_hui_v);
		} else {
			iv_addvsecond.setVisibility(View.GONE);
		}

		if (!"False".equals(shopDetail.getIcon3())) {
			iv_addvthird.setVisibility(View.VISIBLE);
			iv_addvthird.setImageResource(R.drawable.shop_zhe_v);
		} else {
			iv_addvthird.setVisibility(View.GONE);
		}

	}

	// 返回关注操作
	@Override
	public void showClick(HashMap<String, AbsModule> map) {

		if (map.containsKey("0")) {
			if (attentionShopModule.isAttentShopSuccess) {
				AttentionDataHelper helper = new AttentionDataHelper(
						getActivity());
				helper.insertShop(shop);
				attentionShop.put(shopID,
						Integer.valueOf(shopDetail.getAttentionCount()) + 1);
				attentionCount.setText(attentionShop.get(shopID) + "");
				Toast.makeText(getActivity(), "关注成功", Toast.LENGTH_SHORT)
						.show();
			} else {
				Toast.makeText(getActivity(), "已关注", Toast.LENGTH_SHORT).show();
			}
		} else {
			showErrorTip(map);
		}

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.title_newsinfo:
			title_news
					.setBackgroundResource(R.drawable.shopinfo_subview_title_click);
			title_comment.setBackgroundResource(0);
			title_brandofshop.setBackgroundResource(0);
			title_shopdetail.setBackgroundResource(0);
			container.removeAllViews();
			container.addView(subview_newsinfo);
			break;
		case R.id.title_comment:
			title_news.setBackgroundResource(0);
			title_comment
					.setBackgroundResource(R.drawable.shopinfo_subview_title_click);
			title_brandofshop.setBackgroundResource(0);
			title_shopdetail.setBackgroundResource(0);
			container.removeAllViews();
			container.addView(subview_comment);
			break;
		case R.id.title_shopdetail:
			title_news.setBackgroundResource(0);
			title_comment.setBackgroundResource(0);
			title_brandofshop.setBackgroundResource(0);
			title_shopdetail
					.setBackgroundResource(R.drawable.shopinfo_subview_title_click);
			container.removeAllViews();
			container.addView(subview_shopdetail);
			break;
		case R.id.title_brandofshop:
			BrandsOfShopFragment brandsOfShopFragment = new BrandsOfShopFragment();
			Bundle b = new Bundle();
			b.putString("ShopID", shopID);
			brandsOfShopFragment.setArguments(b);
			getFragmentManager().beginTransaction()
					.replace(R.id.fragment, brandsOfShopFragment)
					.addToBackStack(null).commit();

			break;
		case R.id.title_shop_info_back_btn:
			if (IConstants.isHasPush && !IConstants.isHasSelfPush) {
				IConstants.isHasPush = false;
				getActivity().finish();
			} else if (IConstants.isHasSelfPush) {
				// IConstants.isHasSelfPush = false;
				getActivity().finish();
			} else {
				getFragmentManager().popBackStack();
			}
			break;
		case R.id.attention:
			SharePrefenceUtil su = new SharePrefenceUtil(getActivity(),
					IConstants.SP_USER);
			if (su.getUserLoginToken().equals("")) {
				UserLogin();
			} else {
				attentionShopAction = new AttentionShopAction(
						su.getUserLoginToken(), su.getUserID(), shopID);
				attentionShopModule = new AttentionShopModule();
				attentionShopPresistence = new AttentionShopPresistence(this);
				attentionShopPresistence.setActitons(attentionShopAction);
				attentionShopPresistence.setModule(attentionShopModule);
				attentionShopPresistence.execute();
			}
			break;
		case R.id.adverse:
			IConstants.isFromShopFocuse = true;
			PhotoAlbumFragment photoAlbumFragment = new PhotoAlbumFragment();
			Bundle bundle = new Bundle();
			bundle.putString("shopID", shopID);
			photoAlbumFragment.setArguments(bundle);
			getFragmentManager().beginTransaction()
					.replace(R.id.fragment, photoAlbumFragment)
					.addToBackStack(null).commit();
			break;
		case R.id.shop_info_detail_blog_icon:
			String url1 = shopDetail.getWeibo();
			if (url1 != null && !url1.equals("")) {
				FragmentTransaction ft1 = getFragmentManager()
						.beginTransaction();
				WebFragment webFragment1 = new WebFragment();
				Bundle bundle1 = new Bundle();
				bundle1.putString("title", "微博");
				bundle1.putString("url", url1);
				webFragment1.setArguments(bundle1);
				ft1.replace(R.id.fragment, webFragment1);
				ft1.addToBackStack(null);
				ft1.commit();
			}
			break;
		case R.id.shop_info_detail_tel_icon:
			AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
			builder.setTitle("提示");
			builder.setMessage("确定要拨打电话：" + shopDetail.getPhone() + "?");
			builder.setPositiveButton("确定",
					new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							String number = shopDetail.getPhone();
							Intent intent = new Intent(Intent.ACTION_CALL, Uri
									.parse("tel:" + number));
							try {
								startActivity(intent);
							} catch (Exception e) {
								Toast.makeText(getActivity(), "拨打失败",
										Toast.LENGTH_SHORT).show();
							}

						}
					});
			builder.setNegativeButton("取消", null);
			builder.create().show();
			break;
		case R.id.shop_info_detail_map_icon:
			FragmentTransaction ft = getFragmentManager().beginTransaction();
			SingleShopMapFragment map = new SingleShopMapFragment();
			Bundle b1 = new Bundle();
			b1.putSerializable("shop" + 0, shop);
			b1.putInt("size", 1);
			map.setArguments(b1);
			ft.replace(R.id.fragment, map);
			ft.addToBackStack(null);
			ft.commit();
			break;

		case R.id.shop_info_detail_net_icon:
			String url = shopDetail.getWebSiteUrl();
			if (url != null && !url.equals("")) {
				FragmentTransaction ft3 = getFragmentManager()
						.beginTransaction();
				WebFragment webFragment = new WebFragment();
				Bundle b2 = new Bundle();
				b2.putString("url", url);
				b2.putString("title", "官网");
				webFragment.setArguments(b2);
				ft3.replace(R.id.fragment, webFragment);
				ft3.addToBackStack(null);
				ft3.commit();
			}
			break;
		case R.id.shop_info_edit_upload_btn:
			FragmentTransaction ft1 = getFragmentManager().beginTransaction();
			PhotoEditFragment photoEditFragment = new PhotoEditFragment();
			Bundle b6 = new Bundle();
			b6.putString("shopID", shopID);
			photoEditFragment.setArguments(b6);
			ft1.replace(R.id.fragment, photoEditFragment);
			ft1.addToBackStack(null);
			ft1.commit();
			break;
		case R.id.card_link_im:
			CardInfoFragment cardInfoFragment = new CardInfoFragment();
			Bundle b7 = new Bundle();
			b7.putString(CardInfoFragment.CON1, "shop");
			b7.putString(CardInfoFragment.CON1VALUE, shopID);
			cardInfoFragment.setArguments(b7);
			getFragmentManager().beginTransaction()
					.replace(R.id.fragment, cardInfoFragment)
					.addToBackStack(null).commit();

			break;
		default:
			break;
		}

	}

	class DaZhongTask extends AsyncTask<String, integer, DaZhongBean> {
		DaZhongBean daZhongBean;
		String DianPingShopID;
		String apiUrl = "http://api.dianping.com/v1/review/get_recent_reviews";
		String appKey = "131235228"; // 大众点评key值
		String secret = "dad442d7b8d347f6ad58cb1bb366020b"; // 大众点评密码

		public DaZhongTask(String DianPingShopID) {
			this.DianPingShopID = DianPingShopID;
		}

		@Override
		protected DaZhongBean doInBackground(String... params) {
			// TODO Auto-generated method stub
			Map<String, String> paramMap = new HashMap<String, String>();
			paramMap.put("platform", "2");
			paramMap.put("limit", "3");
			paramMap.put("format", "json");
			paramMap.put("business_id", DianPingShopID);
			String requestResult = DaZhongApiTool.requestApi(apiUrl, appKey,
					secret, paramMap);
			daZhongBean = ShopCommentUtil.DaZhongParJson(requestResult);
			return daZhongBean;
		}

		protected void onPostExecute(DaZhongBean daZhongBean) {
			daZhongList = daZhongBean.getDaZhongDetaillist();
			setComment();
		};

	}

	@Override
	public void onRefresh() {
		// TODO Auto-generated method stub

	}

	@Override
	public void onLoadMore() {
		if (!isLoadMore) {
			isLoadMore = true;
			PageIndex++;
			shopInfoNewsAction = new ShopInfoNewsAction(shopID, "1900-1-1",
					String.valueOf(PageIndex));
			shopInfoNewsModule = new ShopInfoNewsModule();
			shopInfoNewsPresistence = new ShopInfoNewsPresistence(this);
			((ManagerActivity) getActivity())
					.addCurrentTask(shopInfoNewsPresistence);
			shopInfoNewsPresistence.setActitons(shopInfoNewsAction);
			shopInfoNewsPresistence.setModule(shopInfoNewsModule);
			shopInfoNewsPresistence.execute();
		}

	}

	@Override
	public void showLoadMore(HashMap<String, AbsModule> map) {
		if (map.containsKey("0")) {
			if (shopInfoNewsModule.newInfoList.size() != 0) {
				for (DiscountInfo discountInfo : shopInfoNewsModule.newInfoList) {
					newInfoList.add(discountInfo);
				}
				newsAdapter.notifyDataSetChanged();
			} else {
				if (getActivity() != null) {
					PageIndex--;
					Toast.makeText(getActivity(), "没有更多", Toast.LENGTH_SHORT)
							.show();
				}
			}
		} else {
			PageIndex--;
			showErrorTip(map);
		}
		newsListView.stopLoadMore();
		isLoadMore = false;
	}

}
